package com.bestdreamer.thread_create;

public class Thread2 implements Runnable {
    private int i ;
    // run() 方法同样是线程执行体
    public void run() {
        for(; i < 100; i++){
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }

    public static void main(String[] args){
        for(int i = 0; i < 100; i++){
            System.out.println(Thread.currentThread().getName() + " " + i);
            if(i == 20){
                Thread2 t2 = new Thread2();
                // 通过 new Thread(target,name) 方法创建新线程
                new Thread(t2,"新线程1").start();
                new Thread(t2,"新线程2").start();
            }
        }
    }
}
